package com.yx.cloud.view;

import android.graphics.drawable.Drawable;
import android.view.View;
import android.widget.Button;
import android.widget.ImageView;
import android.widget.TextView;

import com.yx.cloud.R;


/**
 * 设置 文字、图片显示
 */
public class SetTextImageShow {
    private static final String TAG = "SetTextImageShow";

    /**
     * @param tv:设置数据的view
     * @param content:设置的数据
     * @param view1：需要交提显示隐藏的view
     * @param view2：需要交提显示隐藏的view
     * @param sing：标记true:显示短的，fales:显示长的
     * @param isOnline：标记true:在线，fales:离线
     */
    public static void setStateText(TextView tv, String content, View view1, TextView view2, View view3, boolean sing, boolean isOnline) {
        tv.setText(content);
        view2.setText(content);
        if (sing) {
            view1.setVisibility(View.GONE);
            view2.setVisibility(View.VISIBLE);
        } else {
            view1.setVisibility(View.VISIBLE);
            view2.setVisibility(View.GONE);
        }
        if (isOnline) {
            view3.setBackgroundResource(R.drawable.main_state_bg);
        } else {
            view3.setBackgroundResource(R.drawable.main_offlin_state_bg);
        }
    }

    /**
     * 清扫/回充 状态切换
     *
     * @param rechargeTv：回充状态文本
     * @param rechargeSrc：回充状态文本内容
     * @param rechargeIv：回充状态图标
     * @param rechargeId：回充状态图标ID
     * @param cleanIv：清扫状态图标
     * @param cleanIconId：清扫状态图标ID
     */
    public static void clean_Recharge_StateShow(TextView rechargeTv, String rechargeSrc, Drawable drawable, Button cleanIv, int cleanIconId) {
        rechargeTv.setText(rechargeSrc);
        drawable.setBounds(0, 0, drawable.getMinimumWidth(), drawable.getMinimumHeight());
        rechargeTv.setCompoundDrawables(null, drawable, null, null);
        cleanIv.setBackgroundResource(cleanIconId);
    }

    /**
     * 清扫 状态切换
     *
     * @param rechargeTv：回充状态文本
     * @param rechargeSrc：回充状态文本内容
     * @param rechargeIv：回充状态图标
     * @param rechargeId：回充状态图标ID
     * @param cleanIv：清扫状态图标
     * @param cleanIconId：清扫状态图标ID
     */
    public static void clean_StateShow(Button cleanIv, int cleanIconId) {
//        rechargeTv.setText(rechargeSrc);
//        rechargeIv.setImageResource(rechargeId);

        cleanIv.setBackgroundResource(cleanIconId);
    }

    public static void setText(TextView view, String content) {
        view.setText(content);
    }

    public static void setText(TextView view1, String content1, TextView view2, String content2) {
        view1.setText(content1);
        view2.setText(content2);
    }

    public static void setText(TextView view1, String content1, TextView view2, String content2, TextView view3, String content3) {
        view1.setText(content1);
        view2.setText(content2);
        view3.setText(content3);
    }

    public static void setImage(ImageView view, int iconId) {
        view.setImageResource(iconId);
    }

    public static void setButtonIcon(Button view, int iconId) {
        view.setBackgroundResource(iconId);
    }

    public static void setTextImage(TextView tv, String tvContent, ImageView iv, int ivId) {
        tv.setText(tvContent);
        iv.setImageResource(ivId);
    }

    /***********************************************根据型号进行显示不同的文案****************************************************/


    public static void setTextType(TextView view1, String content1, TextView view2, String content2) {
        view1.setText(content1);
        view2.setText(content2);
    }

    public static void setTextType(TextView view1, String content1, TextView view2, String content2, TextView view3, String content3) {
        view1.setText(content1);
        view2.setText(content2);
        view3.setText(content3);
    }

    public static void setImageType(ImageView view, int iconId) {
        view.setImageResource(iconId);
    }

    public static void setButtonIconType(Button view, int iconId) {
        view.setBackgroundResource(iconId);
    }

    public static void setTextImageType(TextView tv, String tvContent, ImageView iv, int ivId) {
        tv.setText(tvContent);
        iv.setImageResource(ivId);
    }
}
